# -*- coding:utf-8 -*-
# urlError

import urllib.request
import urllib.error

url = 'http://blog.csdn.net/'
try:
    res = urllib.request.urlopen(url)
except urllib.error.URLError as e:
    if hasattr(e, 'code') :
        print(e.code)
    if hasattr(e, 'message'):
        print(e.message)